package com.tedu.bill.demo1;

import java.util.Objects;

/**
 * Author：毕龙
 * Date: 2024/5/9 19:36
 */
public class TestEquals {
    public static void main(String[] args) {
        //问题：== 和equals 的区别
        //==  基本类型   判断两个值是否相同
        int a = 10;
        int b = 20;
        int c = 20;
        System.out.println(a == b);//false
        System.out.println(b == c);//true
        //==  引用类型  判断两个对象的地址是否相同
        Teacher t1 = new Teacher("zirong", 20);
        Teacher t2 = new Teacher("zirong", 20);
        System.out.println(t1 == t2);
        //equals 判断两个对象的内容是否相同  object类中还是判断两个对象的地址是否相同
        System.out.println(t1.equals(t2));

        String str1 = new String("林嘉伟");
        String str2 = new String("林嘉伟");
        //String重写equals方法
        System.out.println(str1.equals(str2));

        //false
        System.out.println("工具类中使用："+Objects.equals(t1,t2));





    }
}
